Page({
  data: {
    avatar: '' || 'http://tmp/mfhxyHDrPVC6ac3b80ed32d47358c19b8f6ce32c1c58.jpeg',
    nickname: '',
  },
  onLoad() {},

  async onShow() {
    const { code, data } = await wx.http.get(
      '/userInfo',
      {},
      {
        header: {
          Authorization: `Bearer ${wx.getStorageSync('token')}`,
        },
      }
    )
    if (code === 10000) {
      getApp().globalData.nickName = data.nickName
      getApp().globalData.avatar = data.avatar
      this.setData({
        avatar: data.avatar,
        nickname: data.nickName,
      })
    }
  },
})
